import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import Layout from '../layout/index.vue'
import HomeView from '../views/expand.vue'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'Layout',
    children: [
      {
        path: '',
        name: 'Home',
        component: HomeView,
        meta: {
          title: '拓展监控'
        }
      },
      // {
      //   path: '/dashboard',
      //   name: 'Dashboard',
      //   component: () => import('../views/DashboardView.vue'),
      //   meta: {
      //     title: '数据大屏'
      //   }
      // },
      // {
      //   path: '/about',
      //   name: 'About',
      //   component: () => import('../views/DashboardView.vue'),
      //   meta: {
      //     title: '关于'
      //   }
      // }
    ]
  }
]

const router = createRouter({
  history: createWebHistory("/screen/"),
  routes
})

// 路由守卫
router.beforeEach((to, from, next) => {
  // 设置页面标题
  if (to.meta.title) {
    document.title = to.meta.title as string
  }
  next()
})

export default router
